package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysStudentHelp;
import com.ruoyi.system.service.ISysStudentHelpService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 帮扶管理Controller
 * 
 * @author ruoyi
 * @date 2023-04-22
 */
@RestController
@RequestMapping("/system/help")
public class SysStudentHelpController extends BaseController
{
    @Autowired
    private ISysStudentHelpService sysStudentHelpService;

    /**
     * 查询帮扶管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:help:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysStudentHelp sysStudentHelp)
    {
        startPage();
        List<SysStudentHelp> list = sysStudentHelpService.selectSysStudentHelpList(sysStudentHelp);
        return getDataTable(list);
    }

    /**
     * 导出帮扶管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:help:export')")
    @Log(title = "帮扶管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysStudentHelp sysStudentHelp)
    {
        List<SysStudentHelp> list = sysStudentHelpService.selectSysStudentHelpList(sysStudentHelp);
        ExcelUtil<SysStudentHelp> util = new ExcelUtil<SysStudentHelp>(SysStudentHelp.class);
        util.exportExcel(response, list, "帮扶管理数据");
    }

    /**
     * 获取帮扶管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:help:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysStudentHelpService.selectSysStudentHelpById(id));
    }

    /**
     * 新增帮扶管理
     */
    @PreAuthorize("@ss.hasPermi('system:help:add')")
    @Log(title = "帮扶管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysStudentHelp sysStudentHelp)
    {
        return toAjax(sysStudentHelpService.insertSysStudentHelp(sysStudentHelp));
    }

    /**
     * 修改帮扶管理
     */
    @PreAuthorize("@ss.hasPermi('system:help:edit')")
    @Log(title = "帮扶管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysStudentHelp sysStudentHelp)
    {
        return toAjax(sysStudentHelpService.updateSysStudentHelp(sysStudentHelp));
    }

    /**
     * 删除帮扶管理
     */
    @PreAuthorize("@ss.hasPermi('system:help:remove')")
    @Log(title = "帮扶管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysStudentHelpService.deleteSysStudentHelpByIds(ids));
    }
}
